<?php

include_once($cfgPaths['lib'].'cms/type/cmsEditType.o.inc.php');

class cmsEditColorType extends cmsEditType {

 function registerFields () {
   $map[] = $this->name.'color';
   $this->map = &$map;
 }

 function render_html () {
  $html  = '<div class="xicstypeplugin">'."\n";
  $html .= '    <h3>'.$this->descr.':</h3>'.$this->showFields()."\n";
  $html  .= '<table border="0" cellspacing="0" cellpadding="0">'."\n";
  $colors = array('FF','CC','99','66','33','00');
  for ($i=0;$i<6;$i++){
    $html  .= "<tr>\n";
    for ($j=0;$j<6;$j++){
      for ($k=0;$k<6;$k++){
          $color = $colors[$i].$colors[$j].$colors[$k];
          $html  .= '<td bgcolor="#'.$color.'"><img src="../0.gif" width="12" height="12" onClick="'.$this->name."chooseColor('#$color'".');" onMouseOver="'.$this->name."showColor('#$color'".');"></td>'."\n";
      }
    }
    $html  .= "</tr>\n";
  }
  $html  .= ' <tr>'."\n";
  $html  .= '   <td colspan="18" bgcolor="'.$this->getValue($this->name.'color').'"><input style="font-family:Courier" type="text" size="7" maxlength="7" name="'.$this->name.'color" value="'.$this->getValue('color').'"><img src="../0.gif" width="12" height="40"></td>'."\n";
  $html  .= '   <td colspan="18" bgcolor="'.$this->getValue($this->name.'color').'" ID="'.$this->name.'colorfield"><img src="../0.gif" width="12" height="40"></td>'."\n";
  $html  .= ' </tr>'."\n";
  $html  .= '</table>'."\n";
  $html  .= '</div><!-- / type color -->'."\n";
  return $html;
 }

 function render_javascript () {
   $n   = $this->name.'text';
   $js  = '  function '.$this->name.'showColor(color){'."\n";
   $js .= '      document.getElementById("'.$this->name.'colorfield").style.background = color;'."\n";
   $js .= '  }'."\n";
   $js .= ''."\n";
   $js .= '  function '.$this->name.'chooseColor(color){'."\n";
   $js .= '    document.dbform.'.$this->name.'color.value = color;'."\n";
   $js .= '  }'."\n";
   return $js;
 }

}


?>